<template>
  <div>
    <button @click="isShow = !isShow">显示/隐藏</button>

<!--  :appear="true" 首次渲染先执行一次
<transition appear>
  -->
    <transition :appear="true">
      <h1 v-show="isShow">你好啊</h1>
    </transition>
  </div>
</template>

<script>
export default {
  name: "Test",
  data() {
    return {
      isShow: true
    }
  }
}
</script>

<style scoped>
h1 {
  background-color: orange;
}

    /* vue默认类名 .v-enter-active .v-leave-active
     <transition name="hello">
     .hello-leave-active{}
     */
    .v-enter-active {
  animation: chengheng 1s;
}

.v-leave-active {
  animation: chengheng 1s reverse;
}


.come {
  animation: chengheng 1s;
}

.go {
  animation: chengheng 1s reverse;
}

/*必须添加这个*/
@keyframes chengheng {
  from {
    transform: translateX(-200px);
  }
  to {
    transform: translateX(0px);
  }
}
</style>